﻿namespace Zann.Iris
{
    using Microsoft.VisualBasic.FileIO;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            decimal[] input = new decimal[] {1.0m, 2.0m, 3.0m};
            
            decimal[][] wt = new decimal[3][];
            wt[0] = new decimal[] { .1m, .2m, .3m, .4m };
            wt[1] = new decimal[] { .5m, .6m, .7m, .8m };
            wt[2] = new decimal[] { .9m, 1.0m, 1.1m, 1.2m };

            decimal[] bias = new decimal[] { -2.0m, -6.0m, -1.0m, -7.0m };

            NeuralNetwork<decimal> nn = new NeuralNetwork<decimal>(input);

            NeuralNetwork<decimal>.ComputeOutput(input, wt, bias);

            Console.ReadLine();
        }

        

    }

    public class NeuralNetwork<T> 
    {
        private T[] inputs;

        public NeuralNetwork(T[] input)
        {
            this.inputs = input;
        }

        public static void ComputeOutput(decimal[] input, decimal[][] weight, decimal[] bias)
        {
            // Parameter check
            if (input.Length != weight.Length)
                throw new ArgumentException("Input and weight argument must have the same length.");

            for (int weightIndex = 0; weightIndex < weight.Length; weightIndex++)
            {
                if (bias.Length != weight[weightIndex].Length)
                    throw new ArgumentException(string.Format("Bias and Weight argument index {0} must have the same length.", weightIndex));
            }

            // Check 
            Console.WriteLine("CHECKED");

            decimal[] result = new decimal[bias.Length];
            
            
            for (int biasIndex = 0; biasIndex < bias.Length; biasIndex++)
            {
                decimal sum = 0;
                for (int inputIndex = 0; inputIndex < input.Length; inputIndex++)
                {
                    sum += input[inputIndex] * weight[inputIndex][biasIndex];
                }
                result[biasIndex] = sum + bias[biasIndex];
            }
            

        }
    }
}
